<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main"/>
        <title>Post List</title>
    </head>
    <body>
        <div class="body">
            <div>
            <g:form action="searchPost" method="get" >
                <input type="text" name="searchKey"><input type="submit" value="搜索">
            </g:form>
            </div>
            <g:if test="${flash.message}">
                <div class="message">${flash.message}</div>
            </g:if>
            
            <div class="list">
                <table class="full">
                    <thead>
                        <tr>

                            <g:sortableColumn property="id" title="Id"/>

                            <g:sortableColumn property="title" title="标题"/>

                            <g:sortableColumn property="dateCreated" title="创建时间"/>

                            <g:sortableColumn property="author.name" title="作者"/>

                            <th>操作</th>

                        </tr>
                    </thead>
                    <tbody>
                        <g:each in="${postInstanceList}" status="i" var="postInstance">
                            <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">

                                <td>${i+1}</td>

                                <td><g:link controller="archive" action="show" id="${postInstance.id}">${fieldValue(bean: postInstance, field: 'title')}</g:link></td>

                                <td>${fieldValue(bean: postInstance, field: 'dateCreated')}</td>

                                <td><g:link controller="home" action="blog" id="${postInstance.author.id}" target="_blank">${fieldValue(bean: postInstance, field: 'author.name')}</g:link></td>

                                <td>
                                <g:link controller="admin" action="postDelete" onclick="return confirm('确定删除此博文吗?');" id="${postInstance.id}">删除</g:link>
                                </td>

                            </tr>
                        </g:each>
                    </tbody>
                </table>
            </div>
            <div class="paginateButtons">
                <g:paginate total="${totalPosts}"/>
            </div>
        </div>
    </body>
</html>
